gdk/x11: Make XInput2 a mandatory build time dependency for x11
authorCarlos Garnacho <carlosg@gnome.org>
Tue, 14 May 2019 21:48:58 +0000 (23:48 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Tue, 14 May 2019 23:05:20 +0000 (01:05 +0200)
XInput2 is more than a decade old already, and the input improvements
there (and in every other backend really) make it untenable to have
support for X11 core input events dragging things behind.

config.h.meson
gdk/x11/gdkdevicemanager-core-x11.c
gdk/x11/gdkdevicemanager-x11.c
gdk/x11/gdkdrag-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdksurface-x11.c
meson.build

index a549f58ecc089cd6d9fe0f0323ba82842432ecde..436e1a15015ed8e0dd9d453c76326e219fe24136 100644 (file)
 #endif
 
 
-/* Define to 1 if XInput 2.0 is available */
-#mesondefine XINPUT_2
-
 /* Define to 1 if XInput 2.2 is available */
 #mesondefine XINPUT_2_2
 
index ee7e3695847626bece423677fcdff8391e9be476..fb740286b5212949d8033990c6d54f5b2891ed15 100644 (file)
@@ -769,10 +769,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
       if (toplevel->has_pointer &&
           !x11_screen->wmspec_check_window &&
           mode != NotifyGrab &&
-#ifdef XINPUT_2
          mode != XINotifyPassiveGrab &&
          mode != XINotifyPassiveUngrab &&
-#endif /* XINPUT_2 */
           mode != NotifyUngrab)
         toplevel->has_pointer_focus = (focus_in) ? FALSE : TRUE;
       G_GNUC_FALLTHROUGH;
@@ -780,10 +778,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
     case NotifyNonlinear:
     case NotifyNonlinearVirtual:
       if (mode != NotifyGrab &&
-#ifdef XINPUT_2
          mode != XINotifyPassiveGrab &&
          mode != XINotifyPassiveUngrab &&
-#endif /* XINPUT_2 */
           mode != NotifyUngrab)
         toplevel->has_focus_window = (focus_in) ? TRUE : FALSE;
       /* We pretend that the focus moves to the grab
@@ -800,10 +796,8 @@ _gdk_device_manager_core_handle_focus (GdkSurface *surface,
        */
       if (!x11_screen->wmspec_check_window &&
           mode != NotifyGrab &&
-#ifdef XINPUT_2
          mode != XINotifyPassiveGrab &&
          mode != XINotifyPassiveUngrab &&
-#endif /* XINPUT_2 */
           mode != NotifyUngrab)
         toplevel->has_pointer_focus = (focus_in) ? TRUE : FALSE;
       break;
index ada4724e7066e7480d6b012bf6aaf08572c01efa..68cd0a06bfe884bc27fdd0611f794e5775bb41ea 100644 (file)
@@ -19,9 +19,7 @@
 
 #include "gdkx11devicemanager-core.h"
 #include "gdkdevicemanagerprivate-core.h"
-#ifdef XINPUT_2
 #include "gdkx11devicemanager-xi2.h"
-#endif
 #include "gdkinternals.h"
 #include "gdkprivate-x11.h"
 #include "gdkdisplay-x11.h"
@@ -39,7 +37,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
 {
   if (!g_getenv ("GDK_CORE_DEVICE_EVENTS"))
     {
-#ifdef XINPUT_2
       int opcode, firstevent, firsterror;
       Display *xdisplay;
 
@@ -70,7 +67,6 @@ _gdk_x11_device_manager_new (GdkDisplay *display)
               return GDK_X11_DEVICE_MANAGER_CORE (device_manager_xi2);
             }
         }
-#endif /* XINPUT_2 */
     }
 
   GDK_DISPLAY_NOTE (display, INPUT, g_message ("Creating core device manager"));
@@ -98,23 +94,20 @@ gdk_x11_device_manager_lookup (GdkX11DeviceManagerCore *device_manager,
 
   g_return_val_if_fail (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager), NULL);
 
-#ifdef XINPUT_2
   if (GDK_IS_X11_DEVICE_MANAGER_XI2 (device_manager))
     device = _gdk_x11_device_manager_xi2_lookup (GDK_X11_DEVICE_MANAGER_XI2 (device_manager),
                                                  device_id);
-  else
-#endif /* XINPUT_2 */
-    if (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager))
-      {
-        /* It is a core/xi1 device manager, we only map
-         * IDs 2 and 3, matching XI2's Virtual Core Pointer
-         * and Keyboard.
-         */
-        if (device_id == VIRTUAL_CORE_POINTER_ID)
-          device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_pointer;
-        else if (device_id == VIRTUAL_CORE_KEYBOARD_ID)
-          device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_keyboard;
-      }
+  else if (GDK_IS_X11_DEVICE_MANAGER_CORE (device_manager))
+    {
+      /* It is a core/xi1 device manager, we only map
+       * IDs 2 and 3, matching XI2's Virtual Core Pointer
+       * and Keyboard.
+       */
+      if (device_id == VIRTUAL_CORE_POINTER_ID)
+        device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_pointer;
+      else if (device_id == VIRTUAL_CORE_KEYBOARD_ID)
+        device = GDK_X11_DEVICE_MANAGER_CORE (device_manager)->core_keyboard;
+    }
 
   return device;
 }
@@ -140,18 +133,15 @@ gdk_x11_device_get_id (GdkDevice *device)
 
   g_return_val_if_fail (GDK_IS_DEVICE (device), 0);
 
-#ifdef XINPUT_2
   if (GDK_IS_X11_DEVICE_XI2 (device))
     device_id = _gdk_x11_device_xi2_get_id (GDK_X11_DEVICE_XI2 (device));
-  else
-#endif /* XINPUT_2 */
-    if (GDK_IS_X11_DEVICE_CORE (device))
-      {
-        if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
-          device_id = VIRTUAL_CORE_KEYBOARD_ID;
-        else
-          device_id = VIRTUAL_CORE_POINTER_ID;
-      }
+  else if (GDK_IS_X11_DEVICE_CORE (device))
+    {
+      if (gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+        device_id = VIRTUAL_CORE_KEYBOARD_ID;
+      else
+        device_id = VIRTUAL_CORE_POINTER_ID;
+    }
 
   return device_id;
 }
index 43779168ff6c01d5426af7793cfdbb24745cb137..aacbbe6095be5442e6a3df9075431312ab616b21 100644 (file)
@@ -1940,11 +1940,9 @@ drag_grab (GdkDrag *drag)
   root = GDK_DISPLAY_XROOTWIN (display);
   seat = gdk_device_get_seat (gdk_drag_get_device (drag));
 
-#ifdef XINPUT_2
   if (GDK_IS_X11_DEVICE_XI2 (device))
     capabilities = GDK_SEAT_CAPABILITY_ALL_POINTING;
   else
-#endif
     capabilities = GDK_SEAT_CAPABILITY_ALL;
 
   cursor = gdk_drag_get_cursor (drag, x11_drag->current_action);
@@ -1966,7 +1964,6 @@ drag_grab (GdkDrag *drag)
       if (keycode == NoSymbol)
         continue;
 
-#ifdef XINPUT_2
       if (GDK_IS_X11_DEVICE_XI2 (device))
         {
           gint deviceid = gdk_x11_device_get_id (gdk_seat_get_keyboard (seat));
@@ -1998,7 +1995,6 @@ drag_grab (GdkDrag *drag)
                          &mods);
         }
       else
-#endif
         {
           XGrabKey (GDK_DISPLAY_XDISPLAY (display),
                     keycode, grab_keys[i].modifiers,
@@ -2040,7 +2036,6 @@ drag_ungrab (GdkDrag *drag)
       if (keycode == NoSymbol)
         continue;
 
-#ifdef XINPUT_2
       if (GDK_IS_X11_DEVICE_XI2 (keyboard))
         {
           XIGrabModifiers mods;
@@ -2057,7 +2052,6 @@ drag_ungrab (GdkDrag *drag)
                            &mods);
         }
       else
-#endif /* XINPUT_2 */
         {
           XUngrabKey (GDK_DISPLAY_XDISPLAY (display),
                       keycode, grab_keys[i].modifiers,
index 813fa81e1c2f236997cee3981a42de62ad603439..2700dcbe564b8d044edef6290650e48e152652b7 100644 (file)
@@ -37,9 +37,7 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#ifdef XINPUT_2
 #include <X11/extensions/XInput2.h>
-#endif
 
 #include <cairo-xlib.h>
 
@@ -134,7 +132,6 @@ void _gdk_x11_device_check_extension_events   (GdkDevice  *device);
 
 GdkX11DeviceManagerCore *_gdk_x11_device_manager_new (GdkDisplay *display);
 
-#ifdef XINPUT_2
 guchar * _gdk_x11_device_xi2_translate_event_mask (GdkX11DeviceManagerXI2 *device_manager_xi2,
                                                    GdkEventMask            event_mask,
                                                    gint                   *len);
@@ -164,7 +161,6 @@ gdouble  gdk_x11_device_xi2_get_last_axis_value (GdkX11DeviceXI2 *device,
 void     gdk_x11_device_xi2_store_axes          (GdkX11DeviceXI2 *device,
                                                  gdouble         *axes,
                                                  gint             n_axes);
-#endif
 
 GdkAtom _gdk_x11_display_manager_atom_intern   (GdkDisplayManager *manager,
                                                 const gchar       *atom_name,
index 9dfeb06703dd9aa61bf86ef9aad5fe648d77fdac..530b80ff2621fbdfc63a39b10c07f79c28d691d1 100644 (file)
@@ -3690,27 +3690,21 @@ handle_wmspec_button_release (GdkDisplay   *display,
   GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
   GdkSurface *surface;
 
-#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
   XIEvent *xiev = (XIEvent *) xevent->xcookie.data;
   XIDeviceEvent *xidev = (XIDeviceEvent *) xiev;
 
   if (xevent->xany.type == GenericEvent)
     surface = gdk_x11_surface_lookup_for_display (display, xidev->event);
   else
-#endif
     surface = gdk_x11_surface_lookup_for_display (display, xevent->xany.window);
 
   if (display_x11->wm_moveresize_button != 0 && surface != NULL)
     {
       if ((xevent->xany.type == ButtonRelease &&
-           xevent->xbutton.button == display_x11->wm_moveresize_button)
-#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
-          ||
+           xevent->xbutton.button == display_x11->wm_moveresize_button) ||
           (xevent->xany.type == GenericEvent &&
            xiev->evtype == XI_ButtonRelease &&
-           xidev->detail == display_x11->wm_moveresize_button)
-#endif
-          )
+           xidev->detail == display_x11->wm_moveresize_button))
         {
           display_x11->wm_moveresize_button = 0;
           wmspec_send_message (display, surface, 0, 0, _NET_WM_MOVERESIZE_CANCEL, 0);
@@ -4102,7 +4096,6 @@ _gdk_x11_moveresize_handle_event (const XEvent *event)
         }
       break;
 
-#if defined (HAVE_XGENERICEVENTS) && defined (XINPUT_2)
     case GenericEvent:
       {
         /* we just assume this is an XI2 event */
@@ -4138,7 +4131,6 @@ _gdk_x11_moveresize_handle_event (const XEvent *event)
           }
       }
       break;
-#endif
 
     default:
       break;
index bbc5aaee31352bf6d643a5af9b85386c8d532b3d..2189ee8b610abcc94db73a03d38db2adb7b84fc7 100644 (file)
@@ -542,18 +542,19 @@ if x11_enabled
     cdata.set('HAVE_XGENERICEVENTS', 1)
   endif
 
-  if xi_dep.found() and cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep)
-    cdata.set('XINPUT_2', 1)
-    # Note that we also check that the XIScrollClassInfo struct is defined,
-    # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(),
-    # but not the XIScrollClassInfo struct
-    has_allow_touch_evens = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep)
-    has_scroll_class_info = cc.has_member('XIScrollClassInfo', 'number', dependencies: xi_dep,
-                                          prefix: '''#include <X11/Xlib.h>
-                                                     #include <X11/extensions/XInput2.h>''')
-    if has_allow_touch_evens and has_scroll_class_info
-      cdata.set('XINPUT_2_2', 1)
-    endif
+  if not xi_dep.found() or not cc.has_header('X11/extensions/XInput2.h', dependencies: xi_dep)
+    error('X11 backend enabled, but XInput2 not found.')
+  endif
+
+  # Note that we also check that the XIScrollClassInfo struct is defined,
+  # because at least Ubuntu Oneiric seems to have XIAllowTouchEvents(),
+  #   but not the XIScrollClassInfo struct
+  has_allow_touch_evens = cc.has_function('XIAllowTouchEvents', dependencies: xi_dep)
+  has_scroll_class_info = cc.has_member('XIScrollClassInfo', 'number', dependencies: xi_dep,
+                                        prefix: '''#include <X11/Xlib.h>
+                                                   #include <X11/extensions/XInput2.h>''')
+  if has_allow_touch_evens and has_scroll_class_info
+    cdata.set('XINPUT_2_2', 1)
   endif
 
   enable_xinerama = get_option('xinerama')